#!/usr/bin/env python
# -*- encoding: UTF-8 -*-
from __future__ import print_function

import os

basedir = os.path.abspath(os.path.dirname(__file__))

class Config:
    PROJECT_DIR = basedir # 工程地址
    SECRET_KEY = os.environ.get('SECRET_KEY') or 'hard to gess string'
    SQLALCHEMY_TRACK_MODIFICATIONS  = True # 跟踪变动,虽然新,但总是出问题,动不动就没有提交或者出现异常
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True
    BOOTSTRAP_SERVE_LOCAL = True # 使用静态文件
    MAIL_SERVER = 'smtp.googlemail.com'
    MAIL_PORT = 587
    MAIL_USE_TLS = True
    MAIL_USERNAME = os.environ.get('MAIL_USERNAME')
    MAIL_PASSWORD = os.environ.get('MAIL_PASSWORD')
    FLASKY_MAIL_SUBJECT_PREFIX = '[Flasky]'
    FLASKY_MAIL_SENDER = 'Flasky Admin <flasky@example.com>'
    FLASKY_ADMIN = os.environ.get('FLASKY_ADMIN')
    
    @staticmethod
    def init_app(app):
        pass
        
class DevelopmentConfig(Config):
    DEBUG = True
    SQLALCHEMY_DATABASE_URI = os.environ.get('DEV_DATABASE_URL') or \
        'sqlite:///' + os.path.join(basedir, 'data-dev.sqlite')


class TestingConfig(Config):
    TESTING = True
    SQLALCHEMY_DATABASE_URI = os.environ.get('TEST_DATABASE_URL') or \
        'sqlite:///' + os.path.join(basedir, 'data-test.sqlite')


class ProductionConfig(Config):
    SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') or \
        'sqlite:///' + os.path.join(basedir, 'data.sqlite')


config = {
    'development': DevelopmentConfig, # 开发环境
    'testing': TestingConfig, # 测试环境
    'production': ProductionConfig, # 生产环境

    'default': DevelopmentConfig # 默认环境
}